import 'dart:convert' show json;

import 'package:freedom/entity/abstract_result.dart';

import 'package:freedom/util/data_type.dart';

class Restful implements AbstractResult<Restful> {
  Restful({
    this.code,
    this.msg,
    this.body,
  });

  factory Restful.fromJson(Map<String, dynamic>? jsonRes) {
    if (jsonRes == null) {
      return Restful();
    }
    return Restful(
      code: asT<String>(jsonRes['code']),
      msg: asT<String>(jsonRes['msg']),
      body: asT<Object>(jsonRes['body']),
    );
  }

  String? code;
  String? msg;
  Object? body;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'code': code,
        'msg': msg,
        'body': body,
      };

  @override
  String toString() {
    return json.encode(this);
  }

  @override
  formJSON(Map<String, dynamic> jsonRes) {
    return Restful.fromJson(jsonRes);
  }

  fromJson(param0) {}
}
